package com.example.springbootbook.service;

import com.example.springbootbook.mapper.UserMapper;
import com.example.springbootbook.model.UserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Slf4j
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;
    public boolean login(UserInfo userInfo) {
        if (!StringUtils.hasLength(userInfo.getUsername()) || !StringUtils.hasLength(userInfo.getPassword())) {
            return false;
        }
        UserInfo userInfo1 = userMapper.getUser(userInfo);
        if (userInfo1 == null) {
            return false;
        }else {
            if (userInfo.getPassword().equals(userInfo1.getPassword())) {
                return true;
            }else {
                return false;
            }
        }
    }
}
